package cn.com.blueInfo.bpm.template.controller;

import cn.com.blueInfo.bpm.common.controller.BaseController;
import cn.com.blueInfo.bpm.common.validation.Create;
import cn.com.blueInfo.bpm.common.validation.Update;
import cn.com.blueInfo.bpm.common.validation.UpdatePartial;
import cn.com.blueInfo.bpm.template.request.ParallelGatewayDTO;
import cn.com.blueInfo.bpm.template.response.ParallelGatewayVO;
import cn.com.blueInfo.bpm.template.service.ParallelGatewayService;
import cn.com.blueInfo.utils.result.ResultInfo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.groups.Default;
import java.util.List;

/**
 * 并行网关表 前端控制器
 * @author suxch
 * @since 2025-08-24 01:41:15
 */
@Tag(name = "并行网关 接口")
@RestController
@RequestMapping("/template/parallelGateway")
public class ParallelGatewayController extends BaseController {

    @Autowired
    private ParallelGatewayService parallelGatewayService;

    /**
     * 新建并行网关
     * @param parallelGatewayDTO 并行网关参数
     * @return ResultInfo
     */
    @Operation(summary = "新增并行网关")
    @PostMapping("/addInfo")
    public ResultInfo<Integer> createParallelGateway(
            @Validated({Create.class, Default.class}) @RequestBody ParallelGatewayDTO parallelGatewayDTO) {
        return parallelGatewayService.addParallelGateway(parallelGatewayDTO);
    }

    /**
     * 批量新建并行网关
     * @param parallelGatewayDTOList 并行网关参数列表
     * @return ResultInfo
     */
    @Operation(summary = "批量新建并行网关")
    @PostMapping("/addInfoList")
    public ResultInfo<Integer> batchCreateParallelGateway(
            @Validated({Create.class, Default.class}) @RequestBody List<ParallelGatewayDTO> parallelGatewayDTOList) {
        return parallelGatewayService.batchAddParallelGateway(parallelGatewayDTOList);
    }

    /**
     * 根据ID删除并行网关
     * @param parallelGatewayId 并行网关ID
     * @return ResultInfo
     */
    @Operation(summary = "根据ID删除并行网关")
    @DeleteMapping("/removeInfo/{parallelGatewayId}")
    public ResultInfo<Integer> deleteParallelGatewayById(
            @Parameter(name = "ID") @PathVariable Long parallelGatewayId) {
        return parallelGatewayService.removeParallelGateway(parallelGatewayId);
    }

    /**
     * 批量根据ID删除并行网关
     * @param parallelGatewayIdList 并行网关ID列表
     * @return ResultInfo
     */
    @Operation(summary = "批量根据ID删除并行网关")
    @DeleteMapping("/removeInfoList/{parallelGatewayIdList}")
    public ResultInfo<Integer> batchDeleteParallelGatewayById(
            @Parameter(name = "ID") @PathVariable List<Long> parallelGatewayIdList) {
        return parallelGatewayService.batchRemoveParallelGateway(parallelGatewayIdList);
    }

    /**
     * 根据ID全量更新并行网关
     * @param parallelGatewayId 并行网关ID
     * @param parallelGatewayDTO 并行网关参数
     * @return ResultInfo
     */
    @Operation(summary = "根据ID全量更新并行网关")
    @PutMapping("/modifyInfo/{parallelGatewayId}")
    public ResultInfo<Integer> updateParallelGatewayFull(
            @Parameter(name = "ID") @PathVariable Long parallelGatewayId,
            @Validated({Update.class, Default.class}) @RequestBody ParallelGatewayDTO parallelGatewayDTO) {
        validateUpdateId(parallelGatewayId, parallelGatewayDTO.getId());
        return parallelGatewayService.modifyParallelGateway(parallelGatewayDTO);
    }

    /**
     * 根据ID部分更新并行网关
     * @param parallelGatewayId 并行网关ID
     * @param parallelGatewayUpdatePartialDTO 并行网关参数
     * @return ResultInfo
     */
    @Operation(summary = "根据ID部分更新并行网关")
    @PatchMapping("/modifyPartialInfo/{parallelGatewayId}")
    public ResultInfo<Integer> updateParallelGatewayPartial(
            @Parameter(name = "ID") @PathVariable Long parallelGatewayId,
            @Validated({UpdatePartial.class, Default.class}) @RequestBody
            ParallelGatewayDTO.UpdatePartialDTO parallelGatewayUpdatePartialDTO) {
        validateUpdateId(parallelGatewayId, parallelGatewayUpdatePartialDTO.getId());
        return parallelGatewayService.modifyParallelGatewayPartial(parallelGatewayUpdatePartialDTO);
    }

    /**
     * 根据ID查询并行网关
     * @param parallelGatewayId 并行网关ID
     * @return ResultInfo
     */
    @Operation(summary = "根据ID查询并行网关")
    @GetMapping("/getInfo/{parallelGatewayId}")
    public ResultInfo<ParallelGatewayVO> getParallelGatewayById(
            @Parameter(name = "ID") @PathVariable Long parallelGatewayId) {
        return parallelGatewayService.queryParallelGatewayById(parallelGatewayId);
    }

    /**
     * 分页查询并行网关
     * @param parallelGatewayQueryDTO 并行网关参数
     * @return ResultInfo
     */
    @Operation(summary = "分页查询并行网关")
    @GetMapping("/getInfos")
    public ResultInfo<Page<ParallelGatewayVO>> getParallelGatewayPage(
            @Validated ParallelGatewayDTO.QueryDTO parallelGatewayQueryDTO) {
        return parallelGatewayService.queryParallelGatewayPage(parallelGatewayQueryDTO);
    }

    /**
     * 根据条件查询并行网关
     * @param parallelGatewayQueryDTO 并行网关参数
     * @return ResultInfo
     */
    @Operation(summary = "根据条件查询并行网关")
    @GetMapping("/getInfoList")
    public ResultInfo<List<ParallelGatewayVO>> getParallelGatewayList(
            @Validated ParallelGatewayDTO.QueryDTO parallelGatewayQueryDTO) {
        return parallelGatewayService.queryParallelGatewayList(parallelGatewayQueryDTO);
    }

}
